package com.example.sls.mapper.admin.defaultProSet;

import com.example.sls.pojo.admin.defaultProSet.DefaultProSet;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface DefaultProSetMapper {

    @Insert("insert into defaultproset values(#{id}, #{proType}, #{content}, #{correctSQL}, #{result})")
    Integer addPro(DefaultProSet querySet);   //添加题目

    @Update("update defaultproset set content = #{content}, correctSQL = #{correctSQL}, result = #{result} where id = #{id}")
    Integer updatePro(Map<String, Object> querySet);  //修改题目(题目类型不用修改)

    @Delete("delete from defaultproset where id = #{id};")
    Integer deleteProById(@Param("id") Integer id);  //删除题目

    @Select("select * from defaultproset where id = #{id}")
    DefaultProSet getProInfoById(@Param("id") Integer id);  //通过id获取题目信息(修改用)

    @Select("select id, proType, content from defaultproset where id = #{id}")
    @Results(id = "proMap", value = {
            @Result(column = "id", property = "id"),
            @Result(column = "proType", property = "proType"),
            @Result(column = "content", property = "content")
    })
    DefaultProSet getProById(@Param("id") Integer id);  //通过id获取题目信息(学生端答题页面)

    @Select("select * from defaultproset")
    List<DefaultProSet> getAllPro();   //查询所有题目


    @Select("select id, content from defaultproset")
    @ResultMap("proMap")
    List<DefaultProSet> getAllPros4Stu();  //给学生返回默认题集的内容(不包含答案)

    @Select("select * from defaultproset where proType = #{proType}")
    List<DefaultProSet> getAllProsByProType(@Param("proType") Integer proType);   //查询指定题型题目(管理员)



    @Select("select id, content from defaultproset ")
    @ResultMap("proMap")
    List<DefaultProSet>getAllPros4StuByProType(@Param("proType") Integer proType);  //查询指定题型题目(学生答题)


    @Select("select count(*) from defaultproset")
    Integer getCount();    //查询题目数量

    @Select("select max(id) from defaultproset")
    Integer getMaxId();   //查询最大题号




}
